home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / Exception.h < prev    next >
C/C++ Source or Header  |  1992-04-27  |  699b  |  31 lines

  1. #ifndef Exception_First
  2. #ifdef __GNUG__
  3. //pragma once
  4. #pragma interface
  5. #endif
  6. #define Exception_First
  7.  
  8. #include <setjmp.h>
  9.  
  10. typedef struct {
  11.     jmp_buf buf;
  12. } ExceptionContext;
  13.  
  14. #define TRY     { ExceptionContext *__old= gException, __curr;  \
  15.           int __code;                                   \
  16.           gException= &__curr;                          \
  17.           if ((__code= setjmp(gException->buf)) == 0) {
  18.           
  19. #define CATCH(n)  gException= __old;                            \
  20.         } else {                                        \
  21.           int n= __code;                                \
  22.           gException= __old;
  23.           
  24. #define ENDTRY  } }
  25.  
  26. extern ExceptionContext *gException;
  27.  
  28. extern void throw(int code);
  29.  
  30. #endif
  31.